//
//  MainNavigationController.swift
//  VVbo
//
//  Created by Mr.Run on 2017/8/21.
//  Copyright © 2017年 Mr.Run. All rights reserved.
//

import UIKit

class MainNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
        navigationBar.isHidden = true
        // Do any additional setup after loading the view.
    }
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        if childViewControllers.count>0 {
            viewController.hidesBottomBarWhenPushed = true
            var title = "返回"
            if childViewControllers.count == 1 {
                title = childViewControllers.first?.title ?? "返回"
            }
            if let vc = viewController as? BaseController {
                vc.navItem.leftBarButtonItem = UIBarButtonItem(title: title, target: self, action: #selector(popToParent), isBack: true)
            }
            
        }
        
        super.pushViewController(viewController, animated: true)
    }
    
    @objc func popToParent() {
        popViewController(animated: true)
    }
    
}
